package com.moxiao.yfjh.module.order.dal.mysql.brokeragewithdraw;

import com.moxiao.yfjh.module.order.controller.admin.brokeragewithdraw.vo.BlindBrokerageWithdrawExportReqVO;
import com.moxiao.yfjh.module.order.controller.admin.brokeragewithdraw.vo.BlindBrokerageWithdrawPageReqVO;
import com.moxiao.yfjh.module.order.controller.admin.brokeragewithdraw.vo.BlindBrokerageWithdrawRespVO;
import java.util.*;

import cn.hutool.core.util.StrUtil;
import com.moxiao.yfjh.framework.common.pojo.PageResult;
import com.moxiao.yfjh.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.moxiao.yfjh.framework.mybatis.core.mapper.BaseMapperX;
import com.moxiao.yfjh.module.blind.dal.dataobject.member.BlindMemberUserDO;
import com.moxiao.yfjh.module.order.controller.admin.brokeragerecord.vo.BlindBrokerageRecordRespVO;
import com.moxiao.yfjh.module.order.dal.dataobject.brokeragerecord.BlindBrokerageRecordDO;
import com.moxiao.yfjh.module.order.dal.dataobject.brokeragewithdraw.BlindBrokerageWithdrawDO;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
import com.moxiao.yfjh.module.order.controller.admin.brokeragewithdraw.vo.*;

/**
 * 相亲佣金提现 Mapper
 *
 * @author mx
 */
@Mapper
public interface BlindBrokerageWithdrawMapper extends BaseMapperX<BlindBrokerageWithdrawDO> {

    default PageResult<BlindBrokerageWithdrawDO> selectPage(BlindBrokerageWithdrawPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BlindBrokerageWithdrawDO>()
                .eqIfPresent(BlindBrokerageWithdrawDO::getUserId, reqVO.getUserId())
                .eqIfPresent(BlindBrokerageWithdrawDO::getPrice, reqVO.getPrice())
                .eqIfPresent(BlindBrokerageWithdrawDO::getFeePrice, reqVO.getFeePrice())
                .eqIfPresent(BlindBrokerageWithdrawDO::getTotalPrice, reqVO.getTotalPrice())
                .eqIfPresent(BlindBrokerageWithdrawDO::getType, reqVO.getType())
                .likeIfPresent(BlindBrokerageWithdrawDO::getName, reqVO.getName())
                .eqIfPresent(BlindBrokerageWithdrawDO::getAccountNo, reqVO.getAccountNo())
                .likeIfPresent(BlindBrokerageWithdrawDO::getBankName, reqVO.getBankName())
                .eqIfPresent(BlindBrokerageWithdrawDO::getBankAddress, reqVO.getBankAddress())
                .eqIfPresent(BlindBrokerageWithdrawDO::getAccountQrCodeUrl, reqVO.getAccountQrCodeUrl())
                .eqIfPresent(BlindBrokerageWithdrawDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BlindBrokerageWithdrawDO::getAuditReason, reqVO.getAuditReason())
                .betweenIfPresent(BlindBrokerageWithdrawDO::getAuditTime, reqVO.getAuditTime())
                .eqIfPresent(BlindBrokerageWithdrawDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(BlindBrokerageWithdrawDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BlindBrokerageWithdrawDO::getId));
    }

    default List<BlindBrokerageWithdrawDO> selectList(BlindBrokerageWithdrawExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BlindBrokerageWithdrawDO>()
                .eqIfPresent(BlindBrokerageWithdrawDO::getUserId, reqVO.getUserId())
                .eqIfPresent(BlindBrokerageWithdrawDO::getPrice, reqVO.getPrice())
                .eqIfPresent(BlindBrokerageWithdrawDO::getFeePrice, reqVO.getFeePrice())
                .eqIfPresent(BlindBrokerageWithdrawDO::getTotalPrice, reqVO.getTotalPrice())
                .eqIfPresent(BlindBrokerageWithdrawDO::getType, reqVO.getType())
                .likeIfPresent(BlindBrokerageWithdrawDO::getName, reqVO.getName())
                .eqIfPresent(BlindBrokerageWithdrawDO::getAccountNo, reqVO.getAccountNo())
                .likeIfPresent(BlindBrokerageWithdrawDO::getBankName, reqVO.getBankName())
                .eqIfPresent(BlindBrokerageWithdrawDO::getBankAddress, reqVO.getBankAddress())
                .eqIfPresent(BlindBrokerageWithdrawDO::getAccountQrCodeUrl, reqVO.getAccountQrCodeUrl())
                .eqIfPresent(BlindBrokerageWithdrawDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BlindBrokerageWithdrawDO::getAuditReason, reqVO.getAuditReason())
                .betweenIfPresent(BlindBrokerageWithdrawDO::getAuditTime, reqVO.getAuditTime())
                .eqIfPresent(BlindBrokerageWithdrawDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(BlindBrokerageWithdrawDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BlindBrokerageWithdrawDO::getId));
    }

    default PageResult<BlindBrokerageWithdrawRespVO> selectJoinPage(BlindBrokerageWithdrawPageReqVO reqVO) {
        return selectJoinPage(reqVO, BlindBrokerageWithdrawRespVO.class, new MPJLambdaWrapper<BlindBrokerageWithdrawDO>()
                .selectAll(BlindBrokerageWithdrawDO.class)
                .leftJoin(BlindMemberUserDO.class, BlindMemberUserDO::getId, BlindBrokerageRecordDO::getUserId)
                .selectAs(BlindMemberUserDO::getNickname, BlindBrokerageRecordRespVO::getNickName)
                .selectAs(BlindMemberUserDO::getMobile, BlindBrokerageRecordRespVO::getMobile)
                .like(StrUtil.isNotBlank(reqVO.getMobile()), BlindMemberUserDO::getMobile, reqVO.getMobile())
                .like(StrUtil.isNotBlank(reqVO.getNickname()), BlindMemberUserDO::getNickname, reqVO.getNickname())
                .eq(reqVO.getUserId() != null, BlindBrokerageRecordDO::getUserId, reqVO.getUserId())
                .eq(reqVO.getStatus() != null, BlindBrokerageRecordDO::getStatus, reqVO.getStatus())
                .orderByDesc(BlindBrokerageWithdrawDO::getCreateTime));
    }
}
